package com.zeratul.common.event.core.handler.redis;

import com.zeratul.common.event.base.BaseSubscribeHandler;
import com.zeratul.common.event.domain.ZtEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;

/**
 * Spring事件监听处理
 */
@Slf4j
public class RedisSubscribeHandler implements BaseSubscribeHandler, MessageListener {


    @Override
    public void onMessage(Message message, byte[] pattern) {
        //反序列化
        ZtEvent<?> ztEvent = deserialize(message.getBody());
        //调用处理方法
        doHandler(ztEvent);
    }
}
